package com.imooc.distributedemo.resume.leetcode;

import java.util.ArrayList;
import java.util.List;

/**
 * leetcode94  二叉树的遍历
 */
public class Solution94 {
    public static void main(String[] args) {
        List<Integer> result = new ArrayList<>();
        MyTreeNode node = new MyTreeNode(1);
        node.right=new MyTreeNode(2);
        node.right.left=new MyTreeNode(3);
        inorder(node,result);
        System.out.println(result);
    }

    public static void inorder(MyTreeNode treeNode,List<Integer> result){
        if(treeNode==null){
            return;
        }
        inorder(treeNode.left,result);
        result.add(treeNode.val);
        inorder(treeNode.right,result);
    }
}

class MyTreeNode {
    int val;
    MyTreeNode left;
    MyTreeNode right;

    MyTreeNode(int x) {
        val = x;
    }
}
